<?php
/**
 * 地址联动相关
 * Created by wwl.
 * User: Administrator
 * Date: 2017/3/17
 * Time: 16:46
 */
namespace Admin\Model;

use Think\Model;

class AddressModel extends Model
{
    const SUCCESS   =0;//成功
    const FAILURE   =1;//失败


    //获取下一级地址数据
    public function getArea_info($area_id,$level,$provinceID)
    {
        $dataSuccess = array('status'=>self::SUCCESS,'msg'=>'成功');
        $dataFailure = array('status'=>self::FAILURE,'msg'=>'异常');
        if (!$area_id || !$level) {
            return $dataFailure;
        }
        $path = WEB_ROOT . '/data/area_info/' . $provinceID . '.php';
        $kv = include_once($path);
        $areaArr = array();
        if ($level == 2) $pid = $provinceID;
        else $pid = $area_id;
        foreach ($kv as $val) {
            if ($val['level'] == $level && $val['p_id'] == $pid) {
                $val['nextLevel'] = $val['level'] + 1;
                $areaArr[] = $val;
            }
        }
        return $areaArr;
    }

}